import type { Response, PageParams, PageResult } from '../types/http';

// 用户相关接口类型
export interface LoginParams {
  username: string;
  password: string;
}

export interface LoginResult {
  token: string;
  userInfo: {
    id: number | string;
    username: string;
    nickname?: string;
    avatar?: string;
    [key: string]: any;
  };
}

// 商品相关接口类型
export interface GoodsItem {
  id: number | string;
  title: string;
  price: number;
  originalPrice: number;
  cover: string;
  description?: string;
  sales?: number;
  stock?: number;
  category?: string;
  tags?: string[];
  [key: string]: any;
}

export interface GoodsListParams extends PageParams {
  categoryId?: string | number;
  keyword?: string;
  sortBy?: 'price' | 'sales' | 'createTime';
  sortOrder?: 'asc' | 'desc';
}

// 购物车相关接口类型
export interface CartItem {
  id: number | string;
  goodsId: number | string;
  goods: GoodsItem;
  quantity: number;
  selected: boolean;
  [key: string]: any;
}

export interface AddToCartParams {
  goodsId: number | string;
  quantity: number;
}

// 订单相关接口类型
export interface OrderItem {
  id: number | string;
  orderNo: string;
  status: number;
  totalAmount: number;
  payAmount: number;
  createTime: string;
  payTime?: string;
  goods: Array<{
    id: number | string;
    goodsId: number | string;
    goods: GoodsItem;
    quantity: number;
    price: number;
  }>;
  [key: string]: any;
}

export interface CreateOrderParams {
  goods: Array<{
    goodsId: number | string;
    quantity: number;
  }>;
  address: {
    name: string;
    phone: string;
    province: string;
    city: string;
    district: string;
    detail: string;
  };
  remark?: string;
}

// 优惠券相关接口类型


// API响应类型
export type LoginResponse = Response<LoginResult>;
export type GoodsListResponse = Response<PageResult<GoodsItem>>;
export type GoodsDetailResponse = Response<GoodsItem>;
export type CartListResponse = Response<CartItem[]>;
export type OrderListResponse = Response<PageResult<OrderItem>>;
export type OrderDetailResponse = Response<OrderItem>;
export type CouponListResponse = Response<Coupon[]>;
export type CouponDetailResponse = Response<Coupon>;